package io.gitee.binaryfox.firework;

import java.util.Random;

/**
 * 测试回拨时间使用
 * 把获取时间戳的改成由这个MOCK获取就会出现时钟回拨
 */
public class ClockBackMock {
    private final static Random random = new Random();
    private static long offset = 0;

    public static long getCurrentTimeMillis() {
        if (random.nextInt(1000) < 100) {
            offset += random.nextInt(10000);
        }
        return System.currentTimeMillis() - offset;
    }

    public static void sleepMock(long ms) {
        offset -= ms;
    }


}
